#ifndef QSYNCPROGRESSWIDGET_H
#define QSYNCPROGRESSWIDGET_H

#include <MLabel>
#include <QtGui/qpainter.h>
#include "QEnmlReader.h"

class QSyncProgressWidget : public MLabel
{
    Q_OBJECT

public:
    QSyncProgressWidget(MWidget* parent = 0)
		:MLabel(trUtf8("Please wait"), parent) {
    	setAlignment(Qt::AlignCenter);
    	setAttribute(Qt::WA_TranslucentBackground);
    	setWordWrap(true);
    	textStyle = "<style>text{color:#999999;font-size:26px;}</style>";
    };

    QSize sizeHint() const {
    	return QSize(500, 100);
    }

    QSize size() const {
    	return sizeHint();
    }

    void showEvent(QShowEvent*) {
		progressCount = 0;
		setText(textStyle + QString(trUtf8("<text>Please wait...</text>")));
	}

public slots:
   	void updateProgressData(QString data) {
   		setText(textStyle + QString(trUtf8("<text>%1\n\n%2</text>")).arg(++progressCount).arg(data));
   	}

protected:
	void paint(QPainter* painter, const QStyleOptionGraphicsItem *option) {
		//p.setBrush(QColor(128, 128, 128, 128));
		painter->setBrush(QColor(0, 0, 0, 128));
		painter->setPen(Qt::NoPen);
		painter->drawRoundedRect(rect(), 25, 25);
		MLabel::paint(painter, option);
    }

private:
    int progressCount;
    QString textStyle;
};

#endif // QSYNCPROGRESSWIDGET_H
